package homework.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Mypackage implements Serializable{
	
	
	private String id;
	public Mypackage(String id,double kilometer, double weigth, int type, String origin, String sender, String recipient,
			String destination) {
		super();
		this.id = id;
		this.kilometer = kilometer;
		this.weigth = weigth;
		this.type = type;
		this.price = calprice(kilometer, weigth, type);
		this.origin = origin;
		this.sender = sender;
		this.recipient = recipient;
		this.destination = destination;
		this.logisticslist = new ArrayList<String>();
		this.logisticslist.add(origin);
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public double getKilometer() {
		return kilometer;
	}


	public void setKilometer(double kilometer) {
		this.kilometer = kilometer;
	}


	public double getWeigth() {
		return weigth;
	}


	public void setWeigth(double weigth) {
		this.weigth = weigth;
	}


	public int getType() {
		return type;
	}


	public void setType(int type) {
		this.type = type;
	}


	public double getPrice() {
		return price;
	}


	public void setPrice(double price) {
		this.price = price;
	}


	public String getOrigin() {
		return origin;
	}


	public void setOrigin(String origin) {
		this.origin = origin;
	}


	public String getSender() {
		return sender;
	}


	public void setSender(String sender) {
		this.sender = sender;
	}


	public String getRecipient() {
		return recipient;
	}


	public void setRecipient(String recipient) {
		this.recipient = recipient;
	}


	public String getDestination() {
		return destination;
	}


	public void setDestination(String destination) {
		this.destination = destination;
	}


	public List<String> getLogisticslist() {
		return logisticslist;
	}


	public void setLogisticslist(List<String> logisticslist) {
		this.logisticslist = logisticslist;
	}


	private double kilometer;
	private double weigth;
	private int type;//1普通 2加急 3轻放
	private double price;
	private String origin;
	private String sender;
	private String recipient;
	private String destination;
	private List<String> logisticslist;
	
	//距离小于100km，重量小于20公斤，收费10元
	//每超过10km，增加1.2元，每超过5公斤，增加1.5元
	//加急模式*1.1倍，轻放模式*1.2倍
	public double calprice(double k,double w,int t) {
		double price =0;
		if(k<0||w<0||(t<0&&t>3)) {
			System.out.println("输入格式有问题");
			price = -1;
		}
		else {
			
			if(k<=100) {
				if(w<=20) {
					price = 10;
				}else {
					price = 10+(w-20)/5*1.5;
				}
			}else {
				if(w<=20) {
					price = 10+(k-100)/10*1.2;
				}else {
					price = 10+(k-100)/10*1.2+(w-20)/5*1.5;
				}
			}
			if(t==2) {
				price*=1.1;
			}else if(t==3) {
				price*=1.2;
			}
		}
		return price;
	
	}
	
	
	
	
	
}
